package com.dc.kylin.rabbitmq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TopicConfig {

    //声明队列
    @Bean
    public Queue topicQueue01(){
        return new Queue("topic01");
    };

    @Bean
    public Queue topicQueue02(){
        return new Queue("topic02");
    };


    //声明exchange
    @Bean
    public TopicExchange setTopicExchange(){
        return new TopicExchange("topicExchange");
    }




    //声明绑定关系
    @Bean
    public Binding bindingTopicExchange01(){
        return BindingBuilder.bind(topicQueue01()).to(setTopicExchange()).with("directBind.*");
    }
    @Bean
    public Binding bindingTopicExchange02(){
        return BindingBuilder.bind(topicQueue02()).to(setTopicExchange()).with("#.two");
    }

}
